﻿Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.IO
Imports DotNetNuke
Namespace NVPortal.Modules.NVNews

    Public MustInherit Class NewsHotSite1
        Inherits Entities.Modules.PortalModuleBase

#Region "Event Handlers"
        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Try
                If Not IsPostBack Then
                    Dim arrNews1 As New ArrayList
                    Dim arrNews2 As New ArrayList
                    Dim arrNews3 As New ArrayList
                    Dim arrNews4 As New ArrayList
                    Dim arrNews5 As New ArrayList
                    Dim arrNews6 As New ArrayList
                    Dim ctlNews As New NV_NewsController
                    arrNews1 = ctlNews.select1hotsite(PortalId)
                    arrNews2 = ctlNews.select2hotsite(PortalId)
                    arrNews3 = ctlNews.select3hotsite(PortalId)
                    arrNews4 = ctlNews.select4hotsite(PortalId)
                    arrNews5 = ctlNews.select5hotsite(PortalId)
                    arrNews6 = ctlNews.select6hotsite(PortalId)
                    'arrNews1 = ctlNews.selectCustomeNews(IIf(Settings("NVNewsCategorySetting") <> "", Settings("NVNewsCategorySetting"), 0), PortalId)
                    If arrNews1.Count > 0 Then
                        Dim objNews1 As NV_NewsInfo
                        objNews1 = CType(arrNews1(0), NV_NewsInfo)
                        Me.lbSummary1.Text = objNews1.Summary
                        Me.hpltitle1.Text = objNews1.Title
                        Me.hpltitle1.NavigateUrl = FormatURL("noidung", objNews1.NewId, objNews1.Title)
                        Me.hpltitle1a.NavigateUrl = FormatURL("noidung", objNews1.NewId, objNews1.Title)
                        If objNews1.ImagePathHOT <> "" Then
                            If objNews1.ImagePathHOT.Contains("http://") Then
                                Me.ImageNews1.Visible = True
                                Me.ImageNews1.ImageUrl = objNews1.ImagePathHOT
                            Else
                                Me.ImageNews1.Visible = True
                                Me.ImageNews1.ImageUrl = PortalSettings.HomeDirectory & "news/hot/" & objNews1.ImagePathHOT
                            End If
                        Else
                            Me.ImageNews1.Visible = False
                        End If
                        If Settings("NVNewsImageValueSetting") <> "" Then
                            Me.ImageNews1.Width = CInt(Split(Settings("NVNewsImageValueSetting"))(0))
                        Else
                            Me.ImageNews1.Width = 426
                            Me.ImageNews1.Height = 286
                        End If


                        If Me.lbSummary1.Visible = False Then
                            Me.hpltitle1.ToolTip = objNews1.Summary
                        End If
                        'arrNews1.RemoveAt(0)
                        'Me.drgOtherNews.DataSource = arrNews
                        'Me.drgOtherNews.DataBind()
                    End If
                    If arrNews2.Count > 0 Then
                        Dim objNews2 As NV_NewsInfo
                        objNews2 = CType(arrNews2(1), NV_NewsInfo)
                        Me.lbSummary2.Text = objNews2.Summary
                        'Me.lbDateTime2.Text = objNews2.Createdate.ToString
                        Me.hpltitle2.Text = objNews2.Title
                        Me.hpltitle2.NavigateUrl = FormatURL("noidung", objNews2.NewId, objNews2.Title)
                        Me.hpltitle2a.NavigateUrl = FormatURL("noidung", objNews2.NewId, objNews2.Title)
                        If objNews2.ImagePathHOT <> "" Then
                            If objNews2.ImagePathHOT.Contains("http://") Then
                                Me.ImageNews2.Visible = True
                                Me.ImageNews2.ImageUrl = objNews2.ImagePathHOT

                            Else
                                Me.ImageNews2.Visible = True
                                Me.ImageNews2.ImageUrl = PortalSettings.HomeDirectory & "news/hot/" & objNews2.ImagePathHOT
                            End If
                        Else
                            Me.ImageNews2.Visible = False
                        End If
                        If Settings("NVNewsImageValueSetting") <> "" Then
                            Me.ImageNews2.Width = CInt(Split(Settings("NVNewsImageValueSetting"))(0))
                        Else
                            Me.ImageNews2.Width = 426
                            Me.ImageNews2.Height = 286
                        End If


                        If Me.lbSummary2.Visible = False Then
                            Me.hpltitle2.ToolTip = objNews2.Summary
                        End If
                        arrNews2.RemoveAt(0)
                        'Me.drgOtherNews.DataSource = arrNews
                        'Me.drgOtherNews.DataBind()
                    End If
                    If arrNews3.Count > 0 Then
                        Dim objNews3 As NV_NewsInfo
                        objNews3 = CType(arrNews3(2), NV_NewsInfo)
                        Me.lbSummary3.Text = objNews3.Summary
                        'Me.lbDateTime3.Text = objNews3.Createdate.ToString
                        Me.hpltitle3.Text = objNews3.Title
                        Me.hpltitle3.NavigateUrl = FormatURL("noidung", objNews3.NewId, objNews3.Title)
                        Me.hpltitle3a.NavigateUrl = FormatURL("noidung", objNews3.NewId, objNews3.Title)
                        If objNews3.ImagePath <> "" Then
                            If objNews3.ImagePathHOT.Contains("http://") Then
                                Me.ImageNews3.Visible = True
                                Me.ImageNews3.ImageUrl = objNews3.ImagePathHOT

                            Else
                                Me.ImageNews3.Visible = True
                                Me.ImageNews3.ImageUrl = PortalSettings.HomeDirectory & "news/hot/" & objNews3.ImagePathHOT
                            End If
                        Else
                            Me.ImageNews3.Visible = False
                        End If
                        If Settings("NVNewsImageValueSetting") <> "" Then
                            Me.ImageNews3.Width = CInt(Split(Settings("NVNewsImageValueSetting"))(0))
                        Else
                            Me.ImageNews3.Width = 426
                            Me.ImageNews3.Height = 286
                        End If


                        If Me.lbSummary3.Visible = False Then
                            Me.hpltitle3.ToolTip = objNews3.Summary
                        End If
                        arrNews3.RemoveAt(0)
                        arrNews3.RemoveAt(0)
                        'Me.drgOtherNews.DataSource = arrNews
                        'Me.drgOtherNews.DataBind()
                    End If
                    If arrNews4.Count > 0 Then
                        Dim objNews4 As NV_NewsInfo
                        objNews4 = CType(arrNews4(3), NV_NewsInfo)
                        Me.lbSummary4.Text = objNews4.Summary
                        'Me.lbDateTime4.Text = objNews4.Createdate.ToString
                        Me.hpltitle4.Text = objNews4.Title
                        Me.hpltitle4.NavigateUrl = FormatURL("noidung", objNews4.NewId, objNews4.Title)
                        Me.hpltitle4a.NavigateUrl = FormatURL("noidung", objNews4.NewId, objNews4.Title)
                        If objNews4.ImagePath <> "" Then
                            If objNews4.ImagePathHOT.Contains("http://") Then
                                Me.ImageNews4.Visible = True
                                Me.ImageNews4.ImageUrl = objNews4.ImagePathHOT

                            Else
                                Me.ImageNews4.Visible = True
                                Me.ImageNews4.ImageUrl = PortalSettings.HomeDirectory & "news/hot/" & objNews4.ImagePathHOT
                            End If
                        Else
                            Me.ImageNews4.Visible = False
                        End If
                        If Settings("NVNewsImageValueSetting") <> "" Then
                            Me.ImageNews4.Width = CInt(Split(Settings("NVNewsImageValueSetting"))(0))
                        Else
                            Me.ImageNews4.Width = 426
                            Me.ImageNews4.Height = 286
                        End If


                        If Me.lbSummary4.Visible = False Then
                            Me.hpltitle4.ToolTip = objNews4.Summary
                        End If
                        arrNews4.RemoveAt(0)
                        arrNews4.RemoveAt(0)
                        arrNews4.RemoveAt(0)
                        'Me.drgOtherNews.DataSource = arrNews
                        'Me.drgOtherNews.DataBind()
                    End If
                    If arrNews5.Count > 0 Then
                        Dim objNews5 As NV_NewsInfo
                        objNews5 = CType(arrNews5(4), NV_NewsInfo)
                        Me.lbSummary5.Text = objNews5.Summary
                        Me.hpltitle5.Text = objNews5.Title
                        Me.hpltitle5.NavigateUrl = FormatURL("noidung", objNews5.NewId, objNews5.Title)
                        Me.hpltitle5a.NavigateUrl = FormatURL("noidung", objNews5.NewId, objNews5.Title)
                        If objNews5.ImagePath <> "" Then
                            If objNews5.ImagePathHOT.Contains("http://") Then
                                Me.ImageNews5.Visible = True
                                Me.ImageNews5.ImageUrl = objNews5.ImagePathHOT

                            Else
                                Me.ImageNews5.Visible = True
                                Me.ImageNews5.ImageUrl = PortalSettings.HomeDirectory & "news/hot/" & objNews5.ImagePathHOT
                            End If
                        Else
                            Me.ImageNews5.Visible = False
                        End If
                        If Settings("NVNewsImageValueSetting") <> "" Then
                            Me.ImageNews5.Width = CInt(Split(Settings("NVNewsImageValueSetting"))(0))
                        Else
                            Me.ImageNews5.Width = 426
                            Me.ImageNews5.Height = 286
                        End If


                        If Me.lbSummary5.Visible = False Then
                            Me.hpltitle5.ToolTip = objNews5.Summary
                        End If
                        arrNews5.RemoveAt(0)
                        arrNews5.RemoveAt(0)
                        arrNews5.RemoveAt(0)
                        arrNews5.RemoveAt(0)
                        'Me.drgOtherNews.DataSource = arrNews
                        'Me.drgOtherNews.DataBind()
                    End If
                End If
            Catch ex As Exception
                ProcessModuleLoadException(Me, ex)
            End Try
        End Sub
        Public Function FormatURL(ByVal sitem As String, ByVal strID As String, ByVal strLink As String) As String
            Return "/" & sitem & "/" & strID & "/" & ReplaceChuoi(strLink) & "/.htm"
        End Function
        Public Function ReplaceChuoi(ByVal chuoi As String) As String
            Dim convert As String = Global.ReplaceChuoi.bodau(chuoi).Replace(" ", "-")
            Return convert
        End Function
#End Region

#Region "Optional Interfaces"

#End Region


    End Class

End Namespace